<?php
/**
 * Created by PhpStorm.
 * User: Administrator
 * Date: 2019/5/20
 * Time: 15:18
 */

namespace app\api\job;

use think\queue\Job;
use app\api\Service\WebsocketService;

class Message
{
    protected $maxTime = 6;

    public function fire(Job $job,$data)
    {
        $websocket = new WebsocketService();
        $res = $websocket->message($data);
        if( $res ){
            echo '执行成功';
            $job->delete();
        }else{
            if( $job->attempts() > $this->maxTime ){
                $job->delete();
            }
        }
        unset($data);
    }
}